package com.chuangke.common.express.function.string;

import java.util.Map;

import com.googlecode.aviator.runtime.function.AbstractFunction;
import com.googlecode.aviator.runtime.function.FunctionUtils;
import com.googlecode.aviator.runtime.type.AviatorObject;
import com.googlecode.aviator.runtime.type.AviatorString;

public class StringAppendFunction extends AbstractFunction {
	
	
    private static final long serialVersionUID = -4749204481686181552L;

	@Override
	public AviatorObject call(Map<String, Object> env, AviatorObject a1 , AviatorObject a2) {
		String s1 = FunctionUtils.getStringValue(a1, env) ;
		String s2 = FunctionUtils.getStringValue(a2, env) ;
		
		return new AviatorString(s1+s2);
	}
	
	@Override
	public AviatorObject call(Map<String, Object> env, AviatorObject a1 , AviatorObject a2, AviatorObject a3) {
		String s1 = FunctionUtils.getStringValue(a1, env) ;
		String s2 = FunctionUtils.getStringValue(a2, env) ;
		String s3 = FunctionUtils.getStringValue(a3, env) ;
		
		return new AviatorString(s1+s2+s3);
	}

	@Override
	public String getName() {
		return "string.append";
	}
}
